Skip to content

servlet: fix write when not ready in AsyncServletOutputStreamWriter#12790

Open
mgustimz wants to merge 1 commit intogrpc:masterfrom
mgustimz:fix/12723-servlet-clean
Open

servlet: fix write when not ready in AsyncServletOutputStreamWriter#12790
mgustimz wants to merge 1 commit intogrpc:masterfrom
mgustimz:fix/12723-servlet-clean

Conversation

@mgustimz
Copy link
Copy Markdown

@mgustimz mgustimz commented May 2, 2026

Description

Even when isReady() returns true, the servlet container may still be processing a previous write internally. Always set readyAndDrained to false after a direct write in runOrBuffer() to ensure subsequent writes go through the container thread via onWritePossible(), matching the servlet spec requirement.

Tomcat throws:

java.lang.IllegalStateException: In non-blocking mode you may not write to the ServletOutputStream until the previous write has completed and isReady() returns true

Testing

Validated by running servlet tests locally. TomcatTransportTest.clientChecksInboundMetadataSize_header passes.

Fixes

Fixes #12723

@mgustimz mgustimz force-pushed the fix/12723-servlet-clean branch from 7f3e6d6 to 3f87103 Compare May 2, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

servlet: TomcatTransportTest detects write when not ready

1 participant